package com.xf.system.utils.smsCode;

import com.xf.system.response.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author xiefengf
 */
@Api(tags = "多因子认证测试类")
@Slf4j
@RestController
@RequestMapping("/login")
public class CodeController {

    @Resource
    private CodeService codeService;

    /**
     * 正常情况下 这里是POST请求，这里为了方便测试，改成GET。入参也需要以请求类接收
     */
    @ApiOperation(value = "发送验证码", httpMethod = "POST")
    @PostMapping("/sendCode")
    public ApiResult<Boolean> sendCode(@RequestParam Long id, @RequestParam Integer multiFactorType){
        return ApiResult.success(codeService.sendCode(id,multiFactorType));
    }

    /**
     * 正常情况下 这里是POST请求，这里为了方便测试，改成GET。入参也需要以请求类接收
     */
    @ApiOperation(value = "多因子认证登录校验，True-成功 False-失败", httpMethod = "POST")
    @PostMapping("/multiFactorLogin")
    public ApiResult<Boolean> multiFactorLogin(@RequestParam Long id, @RequestParam Integer multiFactorType, @RequestParam String code){
        return ApiResult.success(codeService.multiFactorLogin(id,multiFactorType,code));
    }



}
